projectPath=$(pwd)
scriptPath=$(cd $(dirname $0) && pwd)
projectName="${projectPath##*/}"
templatePath=${scriptPath}/template

# echo "projectPath:${projectPath}"
# echo "scriptPath:${scriptPath}"
# echo "projectName:${projectName}"
# echo "templatePath:${templatePath}"
# exit 0

# 初始化git信息
${scriptPath}/git.sh

# 项目文件
if test ! -d ${projectPath}/.vscode; then
    cp -r ${templatePath}/.vscode ${projectPath}/.vscode
fi

# 忽略文件
if test ! -f ${projectPath}/.gitignore; then
    cp ${templatePath}/.gitignore ${projectPath}/.gitignore
fi

# 编译脚本
if test ! -f ${projectPath}/run.sh; then
    cp ${templatePath}/run.sh ${projectPath}/run.sh
fi

# 运行脚本
if test ! -f ${projectPath}/start_for_linux.sh; then
    cp ${templatePath}/start_for_linux.sh ${projectPath}/start_for_linux.sh
fi

# 运行脚本
if test ! -f ${projectPath}/start_for_linux.sh; then
    cp ${templatePath}/start_for_linux.sh ${projectPath}/start_for_linux.sh
fi

echo "======================================="
echo "cat .gitignore"
echo "---------------------------------------"
cat .gitignore
echo "======================================="

# 模块文件
if test ! -f ${projectPath}/go.mod; then
    go mod init ${projectName}
else
    echo
fi

echo "======================================="
echo "cat go.mod"
echo "---------------------------------------"
cat go.mod
echo "======================================="

# 说明文件
if test ! -f ${projectPath}/README.md; then
    echo "# ${projectName}" >${projectPath}/README.md
fi

echo "======================================="
echo "cat README.md"
echo "---------------------------------------"
cat README.md
echo "======================================="

# 配置目录
if test ! -d ${projectPath}/config; then
    mkdir -p ${projectPath}/config
fi

# 日志目录
if test ! -d ${projectPath}/logs; then
    mkdir -p ${projectPath}/logs
    echo "*" >${projectPath}/logs/.gitignore
    echo "!.gitignore" >>${projectPath}/logs/.gitignore
fi

# 测试目录
if test ! -d ${projectPath}/tests; then
    mkdir -p ${projectPath}/tests
fi

# 资源目录
if test ! -d ${projectPath}/resources; then
    mkdir -p ${projectPath}/resources
fi

# 第三方库目录
if test ! -d ${projectPath}/libs; then
    mkdir -p ${projectPath}/libs
fi

# 源码目录
if test ! -f ${projectPath}/main.go; then
    cp -r ${templatePath}/main.go ${projectPath}/main.go
fi

echo "======================================="
echo "cat README.md"
echo "---------------------------------------"
cat main.go
echo "======================================="

# 软连接工具库
# if test ! -d ${projectPath}/stl_utils; then
#     echo "ln -s ../stl_utils ./stl_utils"
#     ln -s ../stl_utils ./stl_utils
# fi
